package com.yonyou.cyxdms.sysAuth.service.controller.gathering;

import com.yonyou.cyxdms.sysAuth.service.dto.gathering.GatheringTypeDTO;
import com.yonyou.cyxdms.sysAuth.service.entity.gathering.GatheringTypePO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.yonyou.cyx.framework.controller.base.BaseController;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;

import com.yonyou.cyxdms.sysAuth.service.service.gathering.GatheringTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;


/**
 * @author adu
 * @since 2019-11-04
 */
@RestController
@RequestMapping("/gathering/gatheringType")
@Api(value = "结算方式管理", tags = {"结算方式管理"})
public class GatheringTypeController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(GatheringTypeController.class);

    @Autowired
    public GatheringTypeService gatheringTypeService;

    /**
     * 分页查询数据
     *
     * @param queryCondition 查询条件
     * @return com.baomidou.mybatisplus.core.metadata.IPage 分页对象
     * @author adu
     * @since 2019-11-04
     */
    @ResponseBody
    @GetMapping
    @ApiOperation(value = "查询-结算方式管理")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public IPage<Map<String, Object>> getList(@RequestParam(required = false) Map<String, Object> queryCondition, @RequestParam
            ("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        Page<Map<String, Object>> page = new Page(currentPage, pageSize);
        return gatheringTypeService.selectPageBysql(page, queryCondition);
    }

    /**
     * 进行数据新增
     *
     * @param gatheringTypeDTO 需要保存的DTO
     * @return Map<String, Object> 返回的数据map
     * @author adu
     * @since 2019-11-04
     */
    @ResponseBody
    @PostMapping
    @ResponseStatus(HttpStatus.OK)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ApiOperation(value = "新增-结算方式")
    public Map<String, Object> insert(@RequestBody GatheringTypeDTO gatheringTypeDTO) {
        logger.debug("gatheringTypeDTO:{}", gatheringTypeDTO);
        return gatheringTypeService.insert(gatheringTypeDTO);
    }

    /**
     * 进行数据修改
     *
     * @param id               需要修改数据的ID
     * @param gatheringTypeDTO 需要保存的DTO
     * @return Map<String, Object> 返回的数据map
     * @author adu
     * @since 2019-11-04
     */
    @ResponseBody
    @PutMapping(value = "/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "编辑-结算方式管理")
    public Map<String, Object> update(@PathVariable("id") Long id, @RequestBody GatheringTypeDTO gatheringTypeDTO) {
        logger.debug("gatheringTypeDTO:{}", gatheringTypeDTO);
        return gatheringTypeService.update(id, gatheringTypeDTO);
    }

    /**
     * 进行数据修改
     *
     * @param id 数据主键ID
     * @return Map<String, Object> 数据对应的map 结构
     * @author adu
     * @since 2019-11-04
     */
/*    @ResponseBody
    @GetMapping(value = "/{id}")
    @SuppressWarnings("unchecked")
    public Map<String, Object> getById(@PathVariable("id") Long id) {
        return gatheringTypeService.getById(id);
    }*/

    /**
     * 根据id删除对象
     *
     * @param id 需要修改数据的ID
     * @author adu
     * @since 2019-11-04
     */
/*    @DeleteMapping(value = "/{id}")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public boolean deleteById(@PathVariable("id") Long id) {
        logger.debug("删除ID:{}", id);
        gatheringTypeService.deleteById(id);
        return true;
    }*/

    /**
     * 根据IDs批量删除对象
     *
     * @param ids 需要修改数据的ID集合
     * @author adu
     * @since 2019-11-04
     */
/*    @DeleteMapping(value = "/batch/{ids}")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public boolean deleteByIds(@PathVariable("ids") String ids) {
        logger.debug("删除ID:{}", ids);
        gatheringTypeService.deleteBatchIds(ids);
        return true;
    }*/


}